package com.showde.shoppingmall.netentity;

import com.kim.net.NetEntity;
import com.showde.shoppingmall.utils.URLS;

public class ProductSearchEntity extends NetEntity {

	public enum FETCH_TYPE {
		/**
		 * 根据分类
		 */
		SEARCH_TYPE_CATEGORY,
		/**
		 * 关键字
		 */
		SEARCH_TYPE_KEYWORD,
		/**
		 * 推荐栏目
		 */
		SEARCH_TYPE_HOT,
		/**
		 * 广告商品
		 */
		SEARCH_TYPE_ADVERTISEMENT,
		/**
		 * 商品ID
		 */
		SEARCH_TYPE_SEPICALPRODUCT,
		/**
		 * 价格排序
		 */
		ORDERBY_JG,
		/**
		 * 销量排序
		 */
		ORDERBY_XL,
		/**
		 * 最新
		 */
		ORDERBY_ZX
	}

	// {"TypeId":1,"OrderBy":"jg"} -- orderby : jg:价格 ， xl:销量 ，zx:最新

	/**
	 * 
	 */
	private static final long serialVersionUID = -5887999718375641500L;

	private String category;
	private String searchKey;
	private String recommend;
	private String advertisement;
	private String sepicalproduct;
	private String sendData;
	private String jgpx;

	public ProductSearchEntity(String param, FETCH_TYPE searchType) {
		initSendData(param, searchType);
	}

	public ProductSearchEntity(FETCH_TYPE searchType) {
		initSendData("1", searchType);
	}

	public ProductSearchEntity(String category, String searchKey) {
		this.category = category;
		this.searchKey = searchKey;
		sendData = "{\"typeId\":" + category + ",\"SearKey\":\"" + searchKey
				+ "\"}";
	}

	public ProductSearchEntity(String searchKey) {
		this.searchKey = searchKey;
		sendData = "{\"SearKey\":\"" + searchKey + "\"}";
	}

	private void initSendData(String param, FETCH_TYPE searchType) {
		switch (searchType) {
		case SEARCH_TYPE_CATEGORY:
			sendData = "{\"TypeId\":" + param + "}";
			break;
		case SEARCH_TYPE_KEYWORD:
			sendData = "{\"SearKey\":\"" + param + "\"}";
			break;
		case SEARCH_TYPE_HOT:
			sendData = "{\"IsHot\":\"1\"}";
			break;
		case SEARCH_TYPE_ADVERTISEMENT:
			sendData = "{\"IsAd\":\"1\"}";
			break;
		case SEARCH_TYPE_SEPICALPRODUCT:
			sendData = "{\"GoodsId\":" + param + "}";
			break;
		case ORDERBY_JG:
			sendData = "{\"TypeId\":1,\"OrderBy\":\"jg\"}";
			break;
		case ORDERBY_XL:
			sendData = "{\"TypeId\":1,\"OrderBy\":\"xl\"}";
			break;
		case ORDERBY_ZX:
			sendData = "{\"TypeId\":1,\"OrderBy\":\"zx\"}";
			break;
		}
	}

	@Override
	public String getSendData() {
		return sendData;
	}

	@Override
	protected void init() {
		this.url = URLS.URL_PRODUCT;
	}

	@Override
	protected void initHttpHeader() {

	}

}
